import java.util.*;

public class Main {
    public static int[][] arr;
    public static Map<Integer, Integer> result;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        arr = new int[n][3];
        for(int i = 0; i < n; i++) {
            arr[i][0] = in.nextInt();
            arr[i][1] = in.nextInt();
            arr[i][2] = in.nextInt();
        }
        result = new HashMap<>();
        if(backtracking(0)) {
            for(int row : result.values()) {
                System.out.print(row + " ");
            }
        }else {
            System.out.println("oops!");
        }
    }

    private static boolean backtracking(int row) {
        if(row >= arr.length) {
            return result.size() == 7;
        }
        for(int num: arr[row]) {
            if(!result.containsKey(num)) {
                result.put(num,row+1);
                if(backtracking(row+1)) {
                    return true;
                }
                if(result.size() == 7) {
                    return true;
                }
                result.remove(num);
            }
        }
        return false;
    }
}